<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <title>Title</title>
    <style>
    html,
    body {
        margin: 0;
        padding: 0;
        position: relative;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    .buttonWrapper {
        width: 100%;
        height: 60%;
        overflow-scrolling: touch;
        overflow-y: scroll;
    }

    button {
        display: block;
        background: #b4282d;
        margin: 20px auto;
        color: white;
        width: 60%;
        height: 44px;
        border-radius: 5px;
        font-size: 1.2rem;
    }

    .text-area {
        box-sizing: border-box;
        padding: 10px;
        width: 100%;
        height: 40%;
        overflow-scrolling: touch;
        overflow-y: scroll;
        color: #666666;
    }
    </style>
</head>

<body>
    <div class="buttonWrapper">
        <button onclick="postRequest()">XMLHttpRequest</button>
    </div>
    <div id="textArea" class="text-area">message:</div>
    <script>
    function log(message) {
        let textArea = document.getElementById("textArea");
        textArea.innerText = textArea.innerText + "\n" + message;
        textArea.scrollTop = textArea.scrollHeight;
    }

    function postRequest() {
        axios.post('/user', {
            firstName: 'Fred',
            lastName: 'Flintstone'
        })
        .then(function (response) {
            log("response from native: " + response.data);
        })
        .catch(function (error) {
            log(error);
        });
    }
    </script>
</body>

</html>
